/**
 * Description: 胸牌Api
 *
 * Created by hrx on 2023/9/18
 */
import service, {IResponseArrayDto, IResponseDto} from "@/utils/ajax";
import type {IBaseQueryDataListParams} from "@/api/index"
import {AxiosResponse} from "axios";

export interface queryBadgeListParam{
  bindFlag?: number,
  electricQuantity?: number,
  userName?: string,
  breastpieceCode?: string
}
export interface queryBadgeBindingUserListParamDTO{
  userName?: string,
  deptIdArrayList?: Array<Array<number>>
}
export interface badgeDetailDTO{
  id: number,
  breastpieceCode?: string,
  electricQuantity?: string,
  networkStatus?: string,
  userName?: string,
  hospitalDeptName?: string,
  bindFlag?: number,
  bindTime?: string,
  createTime?: string
}
export  interface bindUserDataDTO{
  subUserId?: number,
  id?: number
}
// 获取列表
export function getBadgeListApi(data: IBaseQueryDataListParams<queryBadgeListParam>): Promise<AxiosResponse<IResponseDto<IResponseArrayDto<badgeDetailDTO>>>> {
  return service({
    url: '/cloud/device/breastpiece/queryPage',
    method: "post",
    data,
    headers: {
      "showLoading": true
    },
  })
}
// 新增胸牌
export function addBadgeApi(data: badgeDetailDTO): Promise<AxiosResponse<IResponseDto>>{
  return service({
    url: '/cloud/device/breastpiece/create',
    method: "post",
    data,
    headers: {
      "showLoading": true
    },
  })
}
// 绑定人员列表
export function getBadgeUserListApi(data: IBaseQueryDataListParams<queryBadgeBindingUserListParamDTO>): Promise<AxiosResponse<IResponseDto>>{
  return service({
    url: '/cloud/device/breastpiece/selectBindUser',
    method: "post",
    data,
    headers: {
      "showLoading": true
    },
  })
}
// 绑定人员
export function bindUserApi(data: bindUserDataDTO): Promise<AxiosResponse<IResponseDto>>{
  return service({
    url: '/cloud/device/breastpiece/bindUser',
    method: "post",
    data,
    headers: {
      "showLoading": true
    },
  })
}
// 解绑人员
export function unbindUserApi(id: number): Promise<AxiosResponse<IResponseDto>>{
  return service({
    url: `/cloud/device/breastpiece/unbindUser/${id}`,
    method: "get",
    data: {},
    headers: {
      "showLoading": true
    },
  })
}
// 删除胸牌
export function delBadgeApi(id: number): Promise<AxiosResponse<IResponseDto>>{
  return service({
    url: `/cloud/device/breastpiece/deleteById/${id}`,
    method: "get",
    data: {},
    headers: {
      "showLoading": true
    },
  })
}

export function uploadBadgeApi(data: any): Promise<AxiosResponse<IResponseDto>> {
  return service({
    url: '/cloud/device/breastpiece/importBreastpiece',
    method: "post",
    data,
    headers: {
      'Content-Type': 'multipart/form-data;',
      "showLoading": true
    },
  })
}
